package collection;

import java.util.Arrays;
import java.util.List;

/**
 * 数组转集合
 */
public class ArrayToList {
    public static void main(String[] args) {
        String[] array = {"aaa", "bbb", "ccc", "ddd", "eee"};
        System.out.println("array:" + Arrays.toString(array));
        //asList()方法会返回内部的ArrayList,内部直接引用给定数组
        List<String> list = Arrays.asList(array);
        System.out.println("list:" + list);
        //修改数组,list也会修改
        array[1] = "111";
        System.out.println("array:" + Arrays.toString(array));
        System.out.println("list:" + list);

        list.set(2, "222");
        System.out.println("array:" + Arrays.toString(array));
        System.out.println("list:" + list);

        //list.add("333");
    }
}
